package com.zhijiang.util;

import org.bouncycastle.util.encoders.Base64;

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;


/**
 * @author 75936
 * @version 1.0
 * @project zhijiang_hospital_datas
 * @description
 * @date 2023-03-30 10:49:00
 */
public class PasswordUtil {
    private static String KEY = "fxkcfxkcfxkcfxkc";
    private static String IV = "fxkcfxkcfxkcfxkc";


    public static String desEncrypt(String data) {
        try {
            byte[] encrypted1 = new Base64().decode(data);

            Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
            SecretKeySpec keySpec = new SecretKeySpec(KEY.getBytes(), "AES");
            IvParameterSpec ivSpec = new IvParameterSpec(IV.getBytes());
            cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
            byte[] original = cipher.doFinal(encrypted1);
            return new String(original).trim();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

}
